//
//  HTViewController.m
//  今日话题
//
//  Created by 郭海林 on 15/12/3.
//  Copyright © 2015年 郭海林. All rights reserved.
//

#import "HTViewController.h"
#import "HTTableViewController.h"
@interface HTViewController ()<SUNSlideSwitchViewDelegate>

@end

@implementation HTViewController
#pragma mark ----懒加载
- (NSMutableArray *)VCArray{
    if (!_VCArray) {
        _VCArray = [NSMutableArray arrayWithCapacity:5];
    }
    return _VCArray;
}

- (NSMutableArray *)titelArray{
    if (!_titelArray) {
        _titelArray = [NSMutableArray arrayWithCapacity:5];
    }
    return _titelArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    self.slideSwitchView = [[SUNSlideSwitchView alloc] initWithFrame:self.view.frame];
    
    _slideSwitchView.slideSwitchViewDelegate = self;
    
    [self.view addSubview:self.slideSwitchView];
    
    if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
    
    self.slideSwitchView.backgroundColor = [UIColor redColor];
    
    NSArray *array = @[@"最新",@"最热",@"随机",@"深八",@"干货",@"搞笑",@"来玩",@"福利",@"随机",@"萌萌"];
    
    [self.titelArray addObjectsFromArray:array];
    NSLog(@"%lu",_titelArray.count);
    for (int i = 0; i < self.titelArray.count; i++) {
        
        HTTableViewController *taVC = [HTTableViewController new];
        taVC.title = _titelArray[i];
        [self.VCArray addObject:taVC];
    }
    

    NSLog(@"%lu",_VCArray.count);
    
    UIButton *rightSideButton = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [rightSideButton setImage:[UIImage imageNamed:@"xia"] forState:UIControlStateNormal];
    
    [rightSideButton setImage:[UIImage imageNamed:@"icon_rightarrow.png"]  forState:UIControlStateHighlighted];
    
    rightSideButton.frame = CGRectMake(0, 0, 40.0f, 44.0f);
    //    rightSideButton.userInteractionEnabled = NO;
    
//    [rightSideButton addTarget:self action:@selector(click:) forControlEvents:(UIControlEventTouchUpInside)];
    
    self.slideSwitchView.rigthSideButton = rightSideButton;
    
    [self.slideSwitchView buildUI];
    // Do any additional setup after loading the view.
}
- (NSUInteger)numberOfTab:(SUNSlideSwitchView *)view
{
    return _titelArray.count;
}

- (UIViewController *)slideSwitchView:(SUNSlideSwitchView *)view viewOfTab:(NSUInteger)number
{
    
    return self.VCArray[number];
}

- (void)slideSwitchView:(SUNSlideSwitchView *)view didselectTab:(NSUInteger)number
{
    HTTableViewController *VC = nil;
    VC = _VCArray[number];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
